package dataAccess;

import businessEntities.exceptions.ConnectionException;

public class DALConnectionManager {

    public DALConnectionManager() {
        /*Empty*/
    }

    /**
     * Initialize the singleton connection
     * @throws ConnectionException for any exception during the process.
     */
    public void connectDB(String hostName, String userName, String password, String port) {
        SingeltonConnection.silentlyCloseConnection();
        SingeltonConnection.setConnectionParameters(hostName, userName, password, port);
        try {
            SingeltonConnection.getConnection();
        } catch (ConnectionException ex) {
            throw new ConnectionException("Could not initialize connection to the server at " + hostName + ":" + port, ex);
        }
    }

    /**
     * Silently close the connection.
     */
    public static void closeConnection() {
        SingeltonConnection.silentlyCloseConnection();
    }
}
